package com.example.chenjun.myapplication.mvp.presenter;

import com.example.chenjun.myapplication.bean.CookBean;
import com.example.chenjun.myapplication.exeption.CookException;
import com.example.chenjun.myapplication.mvp.contract.SearchCookContract;
import com.example.chenjun.myapplication.net.netcallback.BaseCallback;
import com.example.chenjun.myapplication.net.netcallback.ListCallback2;
import com.example.chenjun.myapplication.util.Logger;

import org.json.JSONObject;

import java.util.List;

public class SearchCookPresenter extends SearchCookContract.AbstractSearchCookPresenter {
    @Override
    public void searchCookPresenter(String searchKey, int index, int size) {
        getModel().searchCookInfo(searchKey, index, size, new ListCallback2<List<CookBean>>() {
            @Override
            public void onResponse(List<CookBean> list) {
                if (isSuccess()) {
                    getView().findSearchCookSuccess(list);
                }else {
                    onError(new CookException(mResultCode, mReason));
                }
            }

            @Override
            public void onError(Exception e) {
                getView().findSearchCookFailed(e);
            }
        });
    }
}
